﻿package plugin.union.game
{
    import com.core.*;
    import morn.core.components.*;
    import morn.core.handlers.*;
    import plugin.union.*;
    import uiresource.union.*;
    import view.mornExtends.*;
    import vo.*;

    public class UnionSalaryGame extends UnionSalaryUI implements IPage
    {
        private var arr:Array;

        public function UnionSalaryGame()
        {
            this.arr = ["第一名行会", "第二名行会", "第三名行会"];
            this.initShow();
            this.initEvent();
            return;
        }// end function

        private function initShow() : void
        {
            var _loc_1:* = ConfigDictionary.data.unionReward;
            list_rank.array = _loc_1;
            list_rank.renderHandler = new Handler(this.rankRender);
            return;
        }// end function

        private function rankRender(param1:Component, param2:int) : void
        {
            var _loc_3:Object = null;
            var _loc_4:Label = null;
            var _loc_5:List = null;
            var _loc_6:Array = null;
            var _loc_7:Array = null;
            var _loc_8:Array = null;
            var _loc_9:Array = null;
            var _loc_10:int = 0;
            var _loc_11:int = 0;
            var _loc_12:int = 0;
            if (param2 < list_rank.length)
            {
                _loc_3 = list_rank.array[param2];
                _loc_4 = param1.getChildByName("txt_name") as Label;
                _loc_4.text = this.arr[param2];
                _loc_5 = param1.getChildByName("list_goods") as List;
                _loc_6 = [];
                _loc_7 = _loc_3.huizhang.split("&");
                _loc_8 = _loc_3.fuhuizhang.split("&");
                _loc_9 = _loc_3.chengyuan.split("&");
                _loc_10 = 0;
                while (_loc_10 < 3)
                {
                    
                    _loc_6.push(_loc_7[_loc_10]);
                    _loc_10++;
                }
                _loc_11 = 0;
                while (_loc_11 < 3)
                {
                    
                    _loc_6.push(_loc_8[_loc_11]);
                    _loc_11++;
                }
                _loc_12 = 0;
                while (_loc_12 < 3)
                {
                    
                    _loc_6.push(_loc_9[_loc_12]);
                    _loc_12++;
                }
                _loc_5.array = _loc_6;
                _loc_5.renderHandler = new Handler(this.goodsRender, [_loc_5]);
            }
            return;
        }// end function

        private function goodsRender(param1:List, param2:Component, param3:int) : void
        {
            var _loc_4:String = null;
            var _loc_5:Array = null;
            var _loc_6:Object = null;
            var _loc_7:Object = null;
            if (param3 < param1.length)
            {
                _loc_4 = param1.array[param3];
                _loc_5 = _loc_4.split("#");
                _loc_6 = ConfigDictionary.data.item;
                _loc_7 = ItemObject.create(_loc_6[_loc_5[0]]);
                _loc_7.count = _loc_5[1];
                (param2 as FlashItem).data = _loc_7;
            }
            return;
        }// end function

        private function initEvent() : void
        {
            btn_lq.clickHandler = new Handler(this.doLq);
            return;
        }// end function

        private function doLq() : void
        {
            UnionSender._28getSalary();
            return;
        }// end function

        public function refresh() : void
        {
            var _loc_4:Object = null;
            var _loc_5:Array = null;
            var _loc_1:* = ModelProxy.getValue("data", "unionSalary");
            var _loc_2:* = ConfigDictionary.data.unionReward;
            var _loc_3:* = UserData.getUserData("name");
            txt_rank.text = "行会当前排名：" + _loc_1.index;
            txt_zw.text = "我的职位：" + (_loc_1.title == 15 ? ("会长") : (_loc_1.title == 10 ? ("副会长") : ("会员")));
            if (_loc_1.index <= 3)
            {
                if (_loc_1.index > 0)
                {
                    _loc_4 = _loc_2[(_loc_1.index - 1)];
                    _loc_5 = [];
                    switch(_loc_1.title)
                    {
                        case 15:
                        {
                            _loc_5 = _loc_4.huizhang.split("&");
                            break;
                        }
                        case 10:
                        {
                            _loc_5 = _loc_4.fuhuizhang.split("&");
                            break;
                        }
                        default:
                        {
                            _loc_5 = _loc_4.chengyuan.split("&");
                            break;
                            break;
                        }
                    }
                }
            }
            list_goods.array = _loc_5;
            list_goods.renderHandler = new Handler(this.goodsRender, [list_goods]);
            btn_lq.disabled = !Boolean(_loc_1.flag);
            return;
        }// end function

        public function update(param1:int, param2:Object) : void
        {
            return;
        }// end function

    }
}
